package com.taotao.service.impl;

import com.taotao.entity.MayiktPayinfo;
import com.taotao.dao.MayiktPayinfoDao;
import com.taotao.service.MayiktPayinfoService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (MayiktPayinfo)表服务实现类
 *
 * @author makejava
 * @since 2022-01-23 21:08:28
 */
@Service
public class MayiktPayinfoServiceImpl implements MayiktPayinfoService {
    @Resource
    private MayiktPayinfoDao mayiktPayinfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param
     * @return 实例对象
     */
    @Override
    public MayiktPayinfo queryById() {
        return this.mayiktPayinfoDao.queryById();
    }

    /**
     * 分页查询
     *
     * @param mayiktPayinfo 筛选条件
     * @param pageRequest   分页对象
     * @return 查询结果
     */
    @Override
    public Page<MayiktPayinfo> queryByPage(MayiktPayinfo mayiktPayinfo, PageRequest pageRequest) {
        long total = this.mayiktPayinfoDao.count(mayiktPayinfo);
        return new PageImpl<>(this.mayiktPayinfoDao.queryAllByLimit(mayiktPayinfo, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param mayiktPayinfo 实例对象
     * @return 实例对象
     */
    @Override
    public MayiktPayinfo insert(MayiktPayinfo mayiktPayinfo) {
        this.mayiktPayinfoDao.insert(mayiktPayinfo);
        return mayiktPayinfo;
    }

    /**
     * 修改数据
     *
     * @param mayiktPayinfo 实例对象
     * @return 实例对象
     */
    @Override
    public MayiktPayinfo update(MayiktPayinfo mayiktPayinfo) {
        this.mayiktPayinfoDao.update(mayiktPayinfo);
        return this.queryById();
    }

    /**
     * 通过主键删除数据
     *
     * @param
     * @return 是否成功
     */
    @Override
    public boolean deleteById() {
        return this.mayiktPayinfoDao.deleteById() > 0;
    }
}
